﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
 

namespace nadModel.ApproverTimeAndExpense
{
    public partial class TimeAndExpenseEntityProcess : AbstractEntityProcess
    {
        public string conection_addr = "http://nad.nadfinlo.com.cn/nad/";

        public TimeAndExpenseEntity[] FindData()
        {
            List<TimeAndExpenseEntity> list = new List<TimeAndExpenseEntity>();
            string sql = "select * from " + TimeAndExpenseEntity.DB_TABLES + " where " + TimeAndExpenseEntity.STATUS + "=0 order by company desc , LaborHedSeq desc";
            TimeAndExpenseEntity[] ens = (TimeAndExpenseEntity[])FindBySql(sql, conection_addr);

            return ens;
        }

        public DataTable ChecklData(TimeAndExpenseEntity t)
        {
           
            string sql = "select company from labordtl where TimeStatus='E'  and  Company='"+t.Company+ "' and EmployeeNum='"+t.Employeenum+ "' and LaborHedSeq='"+t.LaborHedSeq+ "' and LaborType='"+t.LaborTypePseudo+ "' and JobNum='"+t.JobNum+ "' and AssemblySeq='"+t.AssemblySeq+ "' and OprSeq='"+t.OprSeq+ "' and JCDept='"+t.JCDept+ "' and ResourceGrpID='"+t.ResourceGrpID+ "' and ResourceID='" + t.ResourceID+ "' and  PayrollDate ='"+t.PayrollDate+ "' and ClockinTime='"+t.ClockinTime+ "' and  ClockOutTime='"+t.ClockOutTime+"' ";
             
            return (DataTable)ExecuteReader(sql,conection_addr);
        }

        public void UpdateStatus(TimeAndExpenseEntity ent)
        {
            string sql = "update temp_time_and_expense set status=1 where  " + TimeAndExpenseEntity.SYSROWID + "='" + ent.SysRowId + "' ";

            ExecuteNonQuery(sql, conection_addr);
        }
    }
}
